package com.iscreen.core.services.extractor;

import java.io.Serializable;
import java.util.List;

import javax.ejb.ActivationConfigProperty;
import javax.ejb.EJB;
import javax.ejb.MessageDriven;
import javax.jms.MessageListener;

import com.iscreen.core.utils.jms.BaseMDB;
import com.iscreen.core.utils.jms.IScreenQueues;
import com.iscreen.utils.exceptions.IScreenException;

/**
 * Message-Driven Bean implementation class for: DownloaderMDB
 *
 */
@MessageDriven(
		activationConfig = { 
				@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
				@ActivationConfigProperty(propertyName = "destination", propertyValue = IScreenQueues.EXTRACT_QUEUE)
		} )

public class ExtractorMDB extends BaseMDB implements MessageListener {

	@EJB
    private Extractor extractor;

    /**
     * Default constructor. 
     */
    public ExtractorMDB() {
    }


	@Override
	protected Object processMessage(Serializable message)
			throws IScreenException
	{
		ExtractMessage extractMessage = (ExtractMessage) message;
    	System.out.println(extractMessage.getZipFile() + " -> " + extractMessage.getDestinationDir() );
    	List<String> extractedFileNames = extractor.extract(extractMessage);
    	return extractedFileNames;
	}

}
